<!--用户的签到流水页面-->
<template>
  <el-card shadow="never" class="aui-card--fill">
    <div>
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
        <el-form-item>
          <el-button type="primary" @click="SignPointsCk()">积分配置</el-button>
        </el-form-item>
        <el-form-item>
          <el-input v-model="dataForm.userId" placeholder="请输入用户id" clearable></el-input>
        </el-form-item>
        <el-form-item prop="signDate">
          <el-date-picker
              v-model="dataForm.signDate"
              type="date"
              placeholder="请选择签到日期"
              format="yyyy 年 MM 月 dd 日"
              value-format="yyyy-MM-dd"
          />
        </el-form-item>
        <el-form-item>
          <el-button @click="getDataList()">查询</el-button>
        </el-form-item>
<!--        <el-form-item>-->
<!--          <el-button v-if="$hasPermission('api:userRegister:save')" type="primary"-->
<!--                     @click="addOrUpdateHandle()">-->
<!--            新增-->
<!--          </el-button>-->
<!--        </el-form-item>-->
<!--        <el-form-item>-->
<!--          <el-button v-if="$hasPermission('api:userRegister:delete')" type="danger" @click="deleteHandle()">-->
<!--            删除-->
<!--          </el-button>-->
<!--        </el-form-item>-->
      </el-form>
      <el-table v-loading="dataListLoading" :data="dataList" stripe highlight-current-row
                @selection-change="dataListSelectionChangeHandle" @sort-change="dataListSortChangeHandle"
                style="width: 100%;">
        <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
        <el-table-column prop="userId" label="用户id" header-align="center" align="center" width="">
          <template slot-scope="{}" slot="header">
            <!-- 表头名称 -->
            <span>用户信息</span>
            <el-tooltip class="item" effect="dark" placement="top">
              <i class="el-icon-question" style="font-size:16px;"></i>
              <!-- 悬停提示内容 -->
              <div slot="content">
                <div>点击下方名称查看用户详细信息</div>
              </div>
            </el-tooltip>
          </template>
          <template slot-scope="{row}">
            <el-tag size="small" type="primary" style="cursor: pointer;" @click="showUserList(row.userDTO)" v-if="row.userDTO">{{row.userDTO.username}}</el-tag>
            <div v-if="!row.userDTO">{{row.userId}}</div>
          </template>
        </el-table-column>
        <el-table-column prop="points" label="获得积分" header-align="center" align="center" width=""></el-table-column>
        <el-table-column prop="signDate" label="签到日期" header-align="center" align="center" width=""></el-table-column>
        <el-table-column prop="createDate" label="创建日期" header-align="center" align="center"></el-table-column>
      </el-table>
      <el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total"
                     layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle"
                     @current-change="pageCurrentChangeHandle">
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
      <!--查看用户信息组件-->
      <com-user-list :visible.sync="showUser" :content="content"></com-user-list>
      <!--积分配置信息 -->
      <user-registert-sign-points v-if="showSignPoints" ref="userRegistertSignPoints"></user-registert-sign-points>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './userRegisterAddOrUpdate.vue'
import userRegistertSignPoints from './userRegistertSignPointsAddOrUpdate.vue'
export default {
  mixins: [mixinViewModule],
  data() {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/api/userRegister/page',
        getDataListIsPage: true,
        deleteURL: '/api/userRegister',
        deleteIsBatch: true
      },
      showUser:false,                   //是否显示用户信息
      showSignPoints:false,             //是否显示配置信息
      content:{},                       //用户信息内容
      dataForm: {
        id: '',                         //id
        points:'',                      //获得积分
        signDate: '',                   //签到日期
        userId: ''                      //用户id
      },
    }
  },
  components: {
    AddOrUpdate,
    userRegistertSignPoints
  },
  created() {

  },
  methods: {
    //显示用户信息
    showUserList(content){
      this.showUser=true;
      this.content= content;
    },
    // 积分配置新增 / 修改
    SignPointsCk () {
      this.showSignPoints = true
      this.$nextTick(() => {
        this.$refs.userRegistertSignPoints.init()
      })
    },
  }
}
</script>
